package com.ruoyi.energy.controller;


import com.google.common.collect.Maps;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.energy.entity.EnergyOverviewDto;
import com.ruoyi.energy.query.OverviewQuery;
import io.swagger.annotations.ApiOperation;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * 能耗总览
 */
@RequestMapping
@RestController
public class OverviewEnergyController extends BaseController {

    /**
     * 能耗总览 - 目标值
     * @param query
     * @return
     */
    @GetMapping("/overviewEnergy/targetCost")
    public AjaxResult targetCost(OverviewQuery query){
        return AjaxResult.success(100);
    }

    /**
     * 能耗成本
     * @param query
     * @return
     */
    @GetMapping(value = "/overviewEnergy/energyCost")
    public AjaxResult energyCost(OverviewQuery query) {

        return AjaxResult.success(111);
    }

    /**
     * 碳排放量
     * @param query
     * @return
     */
    @GetMapping(value = "/overviewEnergy/carbonEmission")
    public AjaxResult carbonEmission(OverviewQuery query){
        return AjaxResult.success(111);
    }

    /**
     * 生产能耗比
     * @param query
     * @return
     */
    @GetMapping(value = "/overviewEnergy/productEnergyRate")
    public AjaxResult productEnergyRate(OverviewQuery query){
        return AjaxResult.success(111);
    }

    /**
     * 单车能耗比
     * @param query
     * @return
     */
    @GetMapping(value = "/overviewEnergy/singleVehicleCost")
    public AjaxResult singleVehicleCost(OverviewQuery query){
        return AjaxResult.success(111);
    }

    /**
     * 能耗走势
     * 如果查询日期区间小于或等于一天 则展示该日期的24小时的数据，单位为小时
     * @param query
     * @return
     */
    @GetMapping(value = "/overviewEnergy/energyConsumption")
    public AjaxResult energyConsumption(OverviewQuery query){
        Date startTime = query.getStartDateTime();
        Date endTime = query.getEndDateTime();
        long days = (endTime.getTime() - startTime.getTime()) / (24 * 60 * 60 * 1000);
        if (days<=0){
            // 选择日期小于一天  展示当天的二十四小时的数据  分成二十四条

        }else{
            // 查询日期区间内的数据  以天为分组单位
        }
        Map<String , Object> map = new HashMap<String , Object>();
        List<EnergyOverviewDto> list = new ArrayList<EnergyOverviewDto>();
        map.put("2020-01-01", list);
        return AjaxResult.success(map);
    }

    /**
     * 用能成本走势
     * 如果查询日期区间小于或等于一天 则展示该日期的24小时的数据，单位为小时
     * @param query
     * @return
     */
    @GetMapping(value = "/overviewEnergy/energyCcost")
    public AjaxResult energyCcost(OverviewQuery query){
        Date startTime = query.getStartDateTime();
        Date endTime = query.getEndDateTime();
        long days = (endTime.getTime() - startTime.getTime()) / (24 * 60 * 60 * 1000);
        if (days<=0){
            // 选择日期小于一天  展示当天的二十四小时的数据  分成二十四条

        }else{
            // 查询日期区间内的数据  以天为分组单位
        }
        Map<String , Object> map = new HashMap<String , Object>();
        List<EnergyOverviewDto> list = new ArrayList<EnergyOverviewDto>();
        map.put("2020-01-01", list);
        return AjaxResult.success(map);
    }


    /**
     * 能耗数据
     * @param query
     * @return
     */
    @GetMapping(value = "/overviewEnergy/overviewEnergyList")
    public AjaxResult overviewEnergyList(OverviewQuery query){
        Map resMap = Maps.newHashMap();
        // 电能
        resMap.put("elecEnergy", "0.00");
        // 热水
        resMap.put("hotWaterEnergy", "0.00");
        // 冷水
        resMap.put("coldWaterEnergy", "0.00");
        // 天然气
        resMap.put("natGasEnergy", "0.00");
        // 压缩空气
        resMap.put("comAirEnergy", "0.00");
        // 工业水
        resMap.put("indWaterEnergy", "0.00");
        // 废水
        resMap.put("wasteWaterEnergy", "0.00");
        // 纯水
        resMap.put("pureWater", "0.00");
        return AjaxResult.success();
    }

    /**
     * 成本统计
     * @param query
     * @return
     */
    @GetMapping("/overviewEnergy/costConsumption")
    public AjaxResult costConsumption(OverviewQuery query){
        HashMap<String, Object> hashMap = Maps.newHashMap();
        // 资产名称
        hashMap.put("assetName","");
        // 资产代码
        hashMap.put("assetCode","");
        // 能耗成本
        hashMap.put("totalValue","");
        // 节能金额
        hashMap.put("conservationPrice",0);

        return AjaxResult.success(hashMap);
    }

    /**
     * 成本比重
     * @param query
     * @return
     */
    @GetMapping("/overviewEnergy/costConsumption")
    public AjaxResult costRatio(OverviewQuery query){

        Map resMap = Maps.newHashMap();

        // 电能
        Double electricityEnergy = 0.00;
        // 工业用水
        Double waterEnergy = 0.00;
        // 天然气
        Double gasEnergy = 0.00;
        // 压缩空气
        Double comAirEnergy = 0.00;
        //热水
        Double hotWaterEnergy = 0.00;
        //冷水
        Double coldWaterEnergy = 0.00;
        //纯水
        Double pureWater = 0.00;
        //废水
        Double wasteWaterEnergy = 0.00;
        resMap.put("waterEnergy", waterEnergy);
        resMap.put("electricityEnergy", electricityEnergy);
        resMap.put("comAirEnergy", comAirEnergy);
        resMap.put("gasEnergy", gasEnergy);
        resMap.put("hotWaterEnergy", hotWaterEnergy);
        resMap.put("coldWaterEnergy", coldWaterEnergy);
        resMap.put("pureWater", pureWater);
        resMap.put("wasteWaterEnergy", wasteWaterEnergy);

        return AjaxResult.success(resMap);
    }

}
